package com.andkrup.easygame.game {
	import flash.events.EventDispatcher;	
	import flash.events.Event;	
	
	import com.andkrup.easygame.game.objects.map.IMap;	
	
	/**
	 * @author Andkrup
	 * 
	 * This class describes a game mission
	 */
	public class Mission extends EventDispatcher implements IMission {
		private var currentMap:IMap;
		private var _objectives:Array;
		private var chars:Array;

		public function get map():IMap{
			return currentMap;
		}
		public function set map(value:IMap):void{
			currentMap = value;
		}

		public function get objectives():Array{
			return _objectives;
		}
		public function set objectives(value:Array):void{
			_objectives = value;
		}
		
		public function get playerCharacters():Array{
			return chars;
		}
		public function set playerCharacters(value:Array):void{
			chars = value;
		}
		
		public function Mission(){
		}
		
		public function init():void{
			// load map swf and other stuff
			currentMap.addEventListener(Event.INIT, onMapInit, false, 0, true);
			currentMap.init();
		}
		
		private function onMapInit(event:Event):void {
			currentMap.removeEventListener(Event.INIT, onMapInit);
			dispatchEvent(new Event(Event.INIT));
		}
	}
}
